package acwing.prefixSumAndDifferenceArray;


import java.io.*;

public class differenceMatrix {
    static int N = 1010;
    public static void main(String[] args) throws IOException {
        // 创建缓冲输入输出流
        BufferedReader br  = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw  = new BufferedWriter(new OutputStreamWriter(System.out));
        // 得到输入参数
        String[] str1 = br.readLine().split(" ");

        int[][] arr = new int[N][N];
        int[][] b = new int[N][N];

        int n = Integer.parseInt(str1[0]);
        int m = Integer.parseInt(str1[1]);
        int q = Integer.parseInt(str1[2]);

        for (int i = 1; i <= n; i++) {
            String[] str2 = br.readLine().split(" ");
            for (int j = 1; j <= m; j++) {
                // 初始化arr
                arr[i][j] = Integer.parseInt(str2[j - 1]);
                // 初始化b
                b[i][j] = arr[i][j] - arr[i - 1][j] - arr[i][j - 1] + arr[i - 1][j - 1];
            }
        }
        while (q-- != 0) {
            String[] str3 = br.readLine().split(" ");
            int x1 = Integer.parseInt(str3[0]);
            int y1 = Integer.parseInt(str3[1]);
            int x2 = Integer.parseInt(str3[2]);
            int y2 = Integer.parseInt(str3[3]);
            int k = Integer.parseInt(str3[4]);
            b[x1][y1] += k;
            b[x2 + 1][y1] -= k;
            b[x1][y2 + 1] -= k;
            b[x2 + 1][y2 + 1] += k;
        }
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= m; j++) {
                arr[i][j] = arr[i - 1][j] + arr[i][j - 1] - arr[i - 1][j - 1] + b[i][j];
                System.out.print(arr[i][j] + " ");
            }
            System.out.println();
        }
    }
}